HAL OTFDEC migration: Exported types

This section provides information about the HAL OTFDEC types migration.

In HAL2, the OTFDEC is managed as a core driver, and its wrapped by the HAL XSPI driver. For more details about the OTFDEC core APIs, please refer to HAL OTFDEC migration: List of applicable concepts.

HAL OTFDEC state definition

HAL1

HAL2

typedef enum
{
  HAL_OTFDEC_STATE_RESET,
  HAL_OTFDEC_STATE_READY,
  HAL_OTFDEC_STATE_BUSY,
} HAL_OTFDEC_StateTypeDef;
typedef enum
{
  HAL_XSPI_OTFDEC_REGION_STATE_RESET,
  HAL_XSPI_OTFDEC_REGION_STATE_CONFIGURED,
  HAL_XSPI_OTFDEC_REGION_STATE_DECRYPT,
} hal_xspi_otfdec_region_state_t;

Related concept: Revised and optimized HAL state machine


HAL OTFDEC callback ID type definition

HAL1

HAL2

typedef enum
{
  HAL_OTFDEC_ERROR_CB_ID,
  HAL_OTFDEC_MSPINIT_CB_ID,
  HAL_OTFDEC_MSPDEINIT_CB_ID,
} HAL_OTFDEC_CallbackIDTypeDef;
  • Removed from HAL2 : the callback registration is managed by dedicated functions for each OTFDEC event. For more details, see : HAL OTFDEC register callback

  • HAL_OTFDEC_MSPINIT_CB_ID and HAL_OTFDEC_MSPDEINIT_CB_ID are removed because the functions HAL_OTFDEC_MspInit() and HAL_OTFDEC_MspDeInit() are removed.


HAL OTFDEC handle type definition

HAL1

HAL2

OTFDEC_HandleTypeDef;
hal_xspi_handle_t;

Note

No more HAL OTFDEC driver. The OTFDEC is wrapped by HAL XSPI.

Related concept: Renaming of the handle structure


HAL OTFDEC callback pointers

HAL1

HAL2

pOTFDEC_CallbackTypeDef
hal_xspi_cb_t

Note

No more HAL OTFDEC driver. The OTFDEC is wrapped by HAL XSPI.


HAL OTFDEC region configuration type definition

HAL1

HAL2


typedef struct
{
  uint32_t Nonce[2];
  uint32_t StartAddress;
  uint32_t EndAddress;
  uint16_t Version;

} OTFDEC_RegionConfigTypeDef;

In HAL2, the configuration structure includes an additional field that specifies the OTFDEC operating mode.

typedef struct
{
  uint32_t nonce[2];
  uint32_t start_address;
  uint32_t end_address;
  uint16_t version;
  hal_xspi_otfdec_mode_t mode;
} hal_xspi_otfdec_config_t;

Usage example

HAL1

HAL2

hal_otfdec_region_t region = OTFDEC_REGION_1;
OTFDEC_RegionConfigTypeDef config = {0};

uint32_t key_words[4] = {0x71234567U, 0x89ABCDEFU, 0x71234567U, 0x89ABCDEFU};

config.Nonce[0]      = 0xA5A5A5A5U;
config.Nonce[1]      = 0xC3C3C3C3U;
config.StartAddress  = 0x90000000U;
config.EndAddress    = 0x90000FFFU;
config.Version       = 0xDCBAU;

HAL_OTFDEC_RegionSetMode(&hotfdec, region,
                         OTFDEC_REG_MODE_INSTRUCTION_OR_DATA_ACCESSES);

HAL_OTFDEC_RegionSetKey(&hotfdec, region, key_words);

HAL_OTFDEC_RegionConfig(&hotfdec, region, &config,
                        OTFDEC_REG_CONFIGR_LOCK_DISABLE);
hal_xspi_otfdec_region_t region = HAL_XSPI_OTFDEC_REGION_1;
hal_xspi_otfdec_config_t config = {0};
hal_xspi_otfdec_key_t key_config = {0};
uint32_t key_words[4] = {0x71234567U, 0x89ABCDEFU, 0x71234567U, 0x89ABCDEFU};

config.nonce[0]      = 0xA5A5A5A5U;
config.nonce[1]      = 0xC3C3C3C3U;
config.start_address = 0x90000000U;
config.end_address   = 0x90000FFFU;
config.version       = 0xDCBAU;

config.mode          = HAL_XSPI_OTFDEC_MODE_ALL_READ_ACCESS;

key_config.p_key = key_words;
key_config.key_size_byte = HAL_XSPI_OTFDEC_KEY_SIZE_128BIT;

HAL_XSPI_OTFDEC_SetConfigRegion(&hxspi, region, &config, &key_config);